-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix]: Fix null pointer de-reference when parsing statistics from cAdvisor #83
base: main
Are you sure you want to change the base?
[bugfix]: Fix null pointer de-reference when parsing statistics from cAdvisor #83
Conversation
29c9986
to
2de2b11
Compare
/cc @Barakmor1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some small comments overall looks great
Thanks for fixing these bugs!
there might be a situation where pod ranking is done on a freshly created pod whose containers stats are not yet ready in cadvisor. Signed-off-by: Igor Bezukh <[email protected]>
2de2b11
to
8ff1f7c
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
also fixed a bug in swap stats where swap usage stat was assigned with swap available bytes. Signed-off-by: Igor Bezukh <[email protected]>
8ff1f7c
to
39b1889
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Barakmor1 Hey!
Could you have another look please?
@@ -134,7 +135,23 @@ func exceedMemoryLimits(summary summaryFunc) cmpFunc { | |||
func hasContainerExceedMemoryLimits(pod *v1.Pod, summary stats_collector.PodSummary) bool { | |||
for _, container := range pod.Spec.Containers { | |||
if rQuantity, ok := container.Resources.Limits[v1.ResourceMemory]; ok { | |||
memoryAndSwapSumQuantity := memoryAndSwapUsage(*summary.Containers[container.Name].MemoryWorkingSetBytes, *summary.Containers[container.Name].MemorySwapCurrentBytes) | |||
containerStats, exists := summary.Containers[container.Name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Barakmor1 I could avoid code duplication here by appending the regular containers and init containers into a single list, but I prefer to do it in a follow-up, especially that we lack tests to protect us from re-factoring
Signed-off-by: Igor Bezukh [email protected]
Scenario 1: it can happen that API reports about a Pod, but the pod and its containers are not yet
fully created on the node cgroupfs, therefore there can be containers that are missing in the stats.
Scenario 2: Stats API has pointers to counters. Not all counters had default allocation of zero integer.